package com.ChainBizPro.system.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;

/**
 * Description: 库存交易枚举
 * Author: liusijia
 * Date: 2024-12-11
 */
@AllArgsConstructor
@Getter
public enum TransactionTypeEnum {
    /**
     *
     */
    IN("in", "入库"),
    OUT("out", "出库"),
    ;

    private final String key;
    private final String value;

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static TransactionTypeEnum getEnumByValue(String value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (TransactionTypeEnum key : TransactionTypeEnum.values()) {
            if (key.value.equals(value)) {
                return key;
            }
        }
        return null;
    }
}
